~ chicken-core (master) /manual/Module (scheme write)
Trap1[[tags: manual]]
2[[toc:]]
3
4== Module (scheme write)
5
6If port is omitted from any output procedure, it defaults to the value returned by
7(current-output-port). It is an error to attempt an output operation on a
8closed port.
9
10<procedure>(write obj [port9])</procedure>
11
12Writes a representation of obj to the given textual output
13port. Strings that appear in the written representation are enclosed in
14quotation marks, and within those strings backslash and quotation mark
15characters are escaped by backslashes. Symbols that contain non-ASCII
16characters are escaped with vertical lines. Character objects are written using
17the #\ notation.
18
19If obj contains cycles which would cause an infinite loop using the normal written
20representation, then at least the objects that form part of the cycle must be
21represented using datum labels. Datum labels are
22not be used if there are no cycles.
23
24The write procedure returns an unspecified value.
25
26<procedure>(write-shared obj [port])</procedure>
27
28The write-shared procedure is the same as write, except that shared structure
29must be represented using datum labels for all pairs and vectors that appear
30more than once in the output.
31
32<procedure>(write-simple obj [port])</procedure>
33
34The write-simple procedure is the same as write, except that shared structure
35is never represented using datum labels. This can cause write-simple not to
36terminate if
37obj contains circular structure.
38
39<procedure>(display obj [port])</procedure>
40
41Writes a representation of
42obj to the given textual output
43port. Strings that appear in the written representation are output as if by
44write-string instead of by write. Symbols are not escaped. Character objects
45appear in the representation as if written by write-char instead of by write.
46
47The display representation of other objects is unspecified. However, display
48must not loop forever on self-referencing pairs, vectors, or records. Thus if
49the normal write representation is used, datum labels are needed to represent
50cycles as in write.
51
52The display procedure returns an unspecified value.
53
54Rationale: The write procedure is intended for producing machine-readable
55output and display for producing human-readable output.
56
57---
58Previous: [[Module (scheme time)]]
59
60Next: [[Module (chicken base)]]